#pragma once
#include "event.h"
#include "eventInterface.h"

class ConnInfo{//不会主动连接
public:
	ConnInfo(int _f = 0, bool _listen = false);
	~ConnInfo();
	int getFd();
	void setFd(int _f);
	void setRecallHandle(netEvent *_p);
	void closeConn();
public:
	int sendPacketData(const char *buf, unsigned int size);
public:
	struct event ev;
	int fd;
	netEvent *ptr;//回调指针
	bool isListener;
};

class TimerInfo{//不会主动连接
public:
	TimerInfo(int _id = 0);
	~TimerInfo();
	void setId(int _id);
	int getId();
	void setRecallHandle(timeEvent *_p);
public:
	struct event ev;
	int id;
	timeEvent *ptr;//回调指针
};

extern int netInit();
extern typedef void (recall_handle)( const int fd, const short Event, void *args );
extern void netReall( const int fd, const short Event, void *args );
extern int addEvent(ConnInfo &conn, void *args = NULL);
extern int delEvent(ConnInfo &conn, bool closeFd = true);
extern void loopEvent();


extern int addTimer(TimerInfo &timer, int _t, void *args );

